package com.topisv.tms.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.topisv.tms.entity.User;
import com.topisv.tms.repository.UserDao;


@Component
@Transactional(readOnly = true)
public class UserService {

	@Autowired
	private UserDao userDao;

	/**
	 * 查询员工
	 * @param warehouseCode 仓库
	 * @return
	 */
	public List<User> loadByWarehouseCode(String warehouseCode) {
		
		return this.userDao.loadByWarehouseCode(new StringBuilder().append("%").append(warehouseCode).append("%").toString());
		
	}
	
    public User findOne(Long id) {
		
		return this.userDao.findOne(id);
		
	}
	
	
    /**
	 * 查询员工
	 * @param jobuuid
	 * @return User
	 */
	public User findByJobuuid(String jobuuid) {
		return this.userDao.findByJobuuid(jobuuid);
	}
	
	public List<User> findByWareHouseCodeAndCustomerCode(String warehouseCode,String customerCode){
		String warehouseCodeLike=new StringBuilder().append("%").append(warehouseCode).append("%").toString();
		String customerCodeLike=new StringBuilder().append("%").append(customerCode).append("%").toString();
		return userDao.findByWareHouseCodeAndCustomerCode(warehouseCodeLike,customerCodeLike);
	}

	public List<User> findByRealname(String name){
		return userDao.findByRealname(name);
	}
	
}
